<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="<%=request.getContextPath()%>/static/js/jquery-1.8.3.js"></script>
    <script>
        function formatJson(serializeStr){
            var jsonData = {}
            var array = serializeStr.split("&");
            $(array).each(function (i) {
                jsonData[array[i].split("=")[0]] = array[i].split("=")[1];
            });
            return jsonData;
        }
        $(function(){
            $("#submitBtn").click(function () {
                var ser=$("#myform").serialize();
                var jsonData=formatJson(ser);
                console.log(jsonData);
                $.ajax({
                    url:"user/addUser",
                    type:"post",
                    data:JSON.stringify(jsonData),
                    contentType:"application/json"
                });
            });

        });
    </script>
</head>
<body>
    <form id="myform">
        <input type="text" id="telephone" name="telephone">
        <input type="text" id="password" name="password">
        <input type="button" value="提交" id="submitBtn">
    </form>
</body>
</html>
